﻿@page "/Groups/GroupView"
@inherits _BaseView

@using TableViewModel = Maanfee.Dashboard.Domain.ViewModels.GetGroupViewModel

<MaanfeeDashboardPage>
    <MaanfeeDashboardPageHeader PageTitle="@DashboardResource.StringGroup" />

    <MudPaper>
        <MudToolBar>
            <MudText Color="Color.Primary">
                @DashboardResource.StringGroup
            </MudText>
            <MudSpacer />
            <MudIconButton OnClick="@(() => OpenCrudateDialog(0))" Color="Color.Primary" Icon="@Icons.Material.Outlined.Add" Title="@DashboardResource.StringCreate" />
            <MudIconButton OnClick="OnReloadData" Icon="@Icons.Material.Outlined.Refresh" Color="Color.Secondary" Title="@DashboardResource.StringReload" />
            <MudIconButton OnClick="OpenSearchDialog" Icon="@Icons.Material.Filled.ManageSearch" Color="Color.Tertiary" Title="@DashboardResource.StringSearch" />
        </MudToolBar>
    </MudPaper>
    <MudCard>
        <MudDivider DividerType="DividerType.FullWidth" />
        <MudCardActions>
            <MudTable ServerData="ServerData" @ref="Table"
                      Dense="@_IsTableDense" Bordered Striped Hover Virtualize FixedFooter Loading="@IsTableLoading"
                       FixedHeader="@_IsTableFixedHeader" Height="@TableHeight">
                 <HeaderContent>
                     <MudTh Class="column-1x"><MudText Align="Align.Center">#</MudText></MudTh>
                     <MudTh><MudTableSortLabel SortLabel="Title" T="TableViewModel">@DashboardResource.StringTitle</MudTableSortLabel></MudTh>
                        <MudTh Class="column-3x">
                            <MudText Align="Align.Left">
                                <MudMenu Icon="@Icons.Material.Filled.MoreVert" Color="Color.Secondary">
                                    <MudMenuItem OnClick="@(() => _IsTableDense = _IsTableDense ? false : true)">
                                        <MudSwitch @bind-Value="@_IsTableDense" Color="Color.Secondary">
                                            @DashboardResource.StringDense
                                    </MudSwitch>
                                </MudMenuItem>
                                <MudMenuItem OnClick="@(() => _IsTableFixedHeader = _IsTableFixedHeader ? false : true)">
                                    <MudSwitch @bind-Value="@_IsTableFixedHeader" Color="Color.Primary">
                                        @DashboardResource.StringFixedHeader
                                    </MudSwitch>
                                </MudMenuItem>
                                <MudMenuItem OnClick="@(() => OnScrollChanged())">
                                    <MudSwitch @bind-Value="@_IsTableScroll" Color="Color.Tertiary">
                                        @DashboardResource.StringScroll
                                    </MudSwitch>
                                </MudMenuItem>
                            </MudMenu>
                        </MudText>
                    </MudTh>
                </HeaderContent>
                <RowTemplate>
                    <MudTd><MudText Class="text-small-2x" Align="Align.Center">@context.RowNum</MudText></MudTd>
                        <MudTd>
                            @context?.Title
                    </MudTd>
                    <MudTd>
                        <MudIconButton OnClick="()=>OpenDetailsDialog(context.Id)" Title="@DashboardResource.StringDetails" Icon="@Icons.Material.Filled.Details" Color="Color.Primary" Size="Size.Small"></MudIconButton>
                        <MudIconButton OnClick="()=>OpenCrudateDialog(context.Id)" Title="@DashboardResource.StringEdit" Icon="@Icons.Material.Filled.Edit" Color="Color.Success" Size="Size.Small"></MudIconButton>
                        <MudIconButton OnClick="()=>OpenDeleteDialog(context.Id)" Title="@DashboardResource.StringDelete" Icon="@Icons.Material.Filled.Delete" Color="Color.Error" Size="Size.Small"></MudIconButton>
                    </MudTd>
                </RowTemplate>
                <NoRecordsContent>
                    <MudText>@DashboardResource.MessageNoMatchingRecordsFound</MudText>
                    </NoRecordsContent>
                    <LoadingContent>
                        <MudText>@DashboardResource.StringLoading</MudText>
                    </LoadingContent>
                    <PagerContent>
                        <MudTablePager PageSizeOptions="new int[]{10, 50, 100, 200, 500, 1000}" />
                    </PagerContent>
                </MudTable>
            </MudCardActions>
        </MudCard>

    </MaanfeeDashboardPage>
